//
//  signUpVC.m
//  jiaKaoZhuShou
//
//  Created by 金艺社 on 2018/5/17.
//  Copyright © 2018年 金艺社. All rights reserved.
//

#import "signUpVC.h"
#import "detialSectionHeadView.h"
#import "schoolNameCell.h"
#import "studentInformationCell.h"
#import "installmentCell.h"
@interface signUpVC ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *detialView;

@end

@implementation signUpVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"驾校详情";
    CGRect frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight - StatusBarAndNavigationBarHeight - TabbarSafeBottomMargin - 50);
    self.detialView = [[UITableView alloc]initWithFrame:frame];
    if (@available(iOS 11.0, *)) {
        self.detialView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        //        if (iPhoneX) {
        //            self.detialView.contentInset = UIEdgeInsetsMake(0, 0, 88, 0);
        //        }else {
        //            self.detialView.contentInset = UIEdgeInsetsMake(0, 0, 64, 0);
        //        }
        //        self.detialView.scrollIndicatorInsets = self.detialView.contentInset;
    }else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    self.detialView.delegate = self;
    self.detialView.dataSource = self;
    [self.detialView registerNib:[UINib nibWithNibName:NSStringFromClass([schoolNameCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([schoolNameCell class])];
    [self.detialView registerNib:[UINib nibWithNibName:NSStringFromClass([studentInformationCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([studentInformationCell class])];
    [self.detialView registerNib:[UINib nibWithNibName:NSStringFromClass([installmentCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([installmentCell class])];
    [self.view addSubview:self.detialView];
    [self addBootomBtn];
}

#pragma mark --- uitableViewDelegate and dataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 4;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 3) {
        return 8;
    }else if (section == 2) {
        return 3;
    }
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (section == 0) return 0;
    return 40;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 1) {
        return 114;
    }else if (indexPath.section == 2) {
        return 44;
    }
    return 35;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        schoolNameCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([schoolNameCell class])];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }else if (indexPath.section == 1) {
        studentInformationCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([studentInformationCell class])];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }else if (indexPath.section == 2) {
        installmentCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([installmentCell class])];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class])];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:NSStringFromClass([UITableViewCell class])];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.textLabel.text = @"驾校名称";
        cell.textLabel.font = [UIFont customFontOfSize:11];
        cell.detailTextLabel.text = @"杭州驾校";
        cell.detailTextLabel.font = [UIFont customFontOfSize:11];
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    if (section == 0) return nil;
    detialSectionHeadView *view = [[detialSectionHeadView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 40)];
    if (section == 1) [view setTitle:@"学员信息"];
    if (section == 2) [view setTitle:@"分期选择"];
    if (section == 3) [view setTitle:@"课程信息"];
    return view;
}

#pragma mark --- addSubView
- (void)addBootomBtn {
    enum ViewType type = bottom;
    UIButton *customBtn = [UIButton titleOnLeftOfContentWithTitle:@"确认报名" andTitleColorString:@"#FFFFFF" andFont:15 andImageStr:@"" andContainerView:self.view andLocation:type andTitleOnLeft:NO andBackColor:@"#A91E23"];
}
#pragma mark --- bottomViewAction:
- (void)bottomViewAction:(id)sender {
    
}
- (void)dealloc {
    
}

@end
